<?php
$eventTypeField = 'media_eventType_event_field';
$eventNameField = 'media_name_event_field';
$eventIDField = 'media_ID_event_field';
$eventDescriptionField = 'media_description_event_field';
$model->addField($eventNameField);
$model->addField($eventIDField);
$model->addField($eventDescriptionField);
$model->addField($eventTypeField);
$app = Blyn::app()->getActiveApp();

if ($eventId > 0) {
    $eventTable = new BPEventSheet();
    $event = $eventTable->getListById($eventId);
    $eventType = $app->getEventType($event);
    IF ($eventType != NULL) {
        $model->$eventTypeField = $eventType->getId();
    }
    $nameItem = $event->getItem('name');
    if ($nameItem != NULL) {
        $model->$eventNameField = $nameItem->getValue();
    }
    $IDItem = $event->getItem('ID');
    if ($IDItem != NULL) {
        $model->$eventIDField = $IDItem->getValue();
    }
    $descriptionItem = $event->getItem('description');
    if ($descriptionItem != NULL) {
        $model->$eventDescriptionField = $descriptionItem->getValue();
    }
}
?>
<?php
$app = Blyn::app()->getActiveApp();
//$typeList = $app->getEventTypeList();
$typeList = array('微投票','微考勤','微任务');
$list = array('0' => '请选择');
$typeList = $list + $typeList;
?>

<table class="table table-hover">
    <colgroup>
        <col class="span1">
        <col class="span7">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo '属性'; ?></th>
            <th><?php echo '内容'; ?></th>
        </tr>
    </thead>
    <tbody>
        <tr><td> <?php echo '应用名称'; ?> </td>
            <td>
                <?php
                echo $form->textField($model, $eventNameField, array('placeholder' =>'应用名称...', 'required' => true));
                ?>
            </td>
        </tr> 
        <tr>
            <td>
                <?php echo '应用类型'; ?>
            </td>
            <td>
                <?php
                echo $form->dropDownList($model, $eventTypeField, $typeList, array('class' => 'span7'));
                ?>
            </td>
        </tr>
        <tr><td> <?php echo '应用ID'; ?> </td>
            <td>
                <?php
                echo $form->textField($model, $eventIDField, array('placeholder' =>'仅需填写数字ID', 'required' => true));
                ?>
            </td>
        </tr>    
    </tbody>
</table>
         <label class="control-label">
             <?php 
               echo $control->getAjaxLink(array('name' => '点击这里查看帮助', 'id' => 'getHelpAddWeChatQy'), array(
             'htmlOptions' => array()
              ));
             ?>
         </label>